import Vue from 'vue'
import VueRouter from 'vue-router'
import Reg from '@/views/Reg/Reg.vue'
import Login from '@/views/Login/Login.vue'
import Home from '@/views/Home/Home.vue'
import Welcome from '@/views/Home/Welcome.vue'
import userInfo from '@/views/User/userInfo.vue'
import UserAvatar from '@/views/User/UserAvatar.vue'
import UserPwd from '@/views/User/UserPwd.vue'
import ArtCate from '@/views/Article/ArtCate.vue'
import ArticleList from '@/views/Article/ArticleList.vue'
Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}
const routes = [

  { path: '/reg', component: Reg },
  { path: '/login', component: Login },
  {
    path: '/', component: Home,
    redirect: '/home',
    children: [
      //不写路径就默认显示这个页面
      { path: 'home', component: Welcome },
      //这个路由地址不能随便写，必须是动态菜单的indexPath（后台规定的）
      { path: 'user-info', component: userInfo },
      { path: 'User-avatar', component: UserAvatar },
      { path: 'User-pwd', component: UserPwd },
      { path: 'art-cate', component: ArtCate },
      { path: 'art-list', component: ArticleList }

    ]
  },

]

const router = new VueRouter({
  routes
})

export default router
